// 云函数入口文件
const cloud = require('wx-server-sdk')
const TcbRputer = require('tcb-router')
cloud.init({
  env: cloud.DYNAMIC_CURRENT_ENV,
  traceUser: true,
})

// 云函数入口函数
exports.main = async (event, context) => {
  const app = new TcbRputer({ event })
  app.use(async (ctx, next) => {
    ctx.data = {}
    ctx.data.openId = event.userInfo.openId
    await next()
  })

  app.router('music', async (ctx, next) => {
    ctx.data.musicname = '啦啦啦'
    await next()
  }), async (ctx, next) => {
    ctx.data.musicType = '儿歌'
    ctx.body = {
      data: ctx.data
    }
  }



  return app.serve()
}